<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Linux基础常用命令 - 记录从零开始的过程</title><meta name="Description" content="记录从零开始的过程"><meta property="og:title" content="Linux基础常用命令" />
<meta property="og:description" content="持续更新基础常用的命令" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://example.org/%E5%9F%BA%E7%A1%80%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" /><meta property="og:image" content="http://example.org/logo.png"/><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2021-11-10T14:32:37+08:00" />
<meta property="article:modified_time" content="2021-11-10T14:32:37+08:00" />

<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="http://example.org/logo.png"/>

<meta name="twitter:title" content="Linux基础常用命令"/>
<meta name="twitter:description" content="持续更新基础常用的命令"/>
<meta name="application-name" content="LoveIt">
<meta name="apple-mobile-web-app-title" content="LoveIt"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="http://example.org/%E5%9F%BA%E7%A1%80%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" /><link rel="prev" href="http://example.org/yum/" /><link rel="next" href="http://example.org/%E7%B3%BB%E7%BB%9F%E7%9B%AE%E5%BD%95/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Linux基础常用命令",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "http:\/\/example.org\/%E5%9F%BA%E7%A1%80%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4\/"
        },"genre": "posts","keywords": "Linux","wordcount":  566 ,
        "url": "http:\/\/example.org\/%E5%9F%BA%E7%A1%80%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4\/","datePublished": "2021-11-10T14:32:37+08:00","dateModified": "2021-11-10T14:32:37+08:00","publisher": {
            "@type": "Organization",
            "name": ""},"author": {
                "@type": "Person",
                "name": "Cuasloi"
            },"description": ""
    }
    </script></head>
    <body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('auto' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : 'auto' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="记录从零开始的过程">Cuasloi</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="记录从零开始的过程">Cuasloi</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Linux基础常用命令</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>Cuasloi</a></span>&nbsp;<span class="post-category">收录于 <a href="/categories/linux/"><i class="far fa-folder fa-fw"></i>Linux</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2021-11-10">2021-11-10</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 566 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 2 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#帮助">帮助</a></li>
    <li><a href="#关机重启">关机、重启</a></li>
    <li><a href="#目录或文件操作">目录或文件操作</a>
      <ul>
        <li><a href="#切换目录">切换目录</a></li>
        <li><a href="#查看目录">查看目录</a></li>
        <li><a href="#查看文件">查看文件</a></li>
        <li><a href="#创建">创建</a></li>
        <li><a href="#删除">删除</a></li>
        <li><a href="#修改">修改</a></li>
        <li><a href="#搜索">搜索</a></li>
      </ul>
    </li>
    <li><a href="#系统">系统</a></li>
    <li><a href="#压缩文件">压缩文件</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><p>持续更新基础常用的命令</p>
<h2 id="帮助">帮助</h2>
<ul>
<li><code>man shutdown</code> 查看<strong>shutdown</strong>命令说明</li>
<li><code>shutdown --help</code> 查看<strong>shutdown</strong>命令帮助</li>
</ul>
<h2 id="关机重启">关机、重启</h2>
<ul>
<li><code>shutdown -h now</code> 立刻关机</li>
<li><code>shutdown -h 5</code> 五分钟后关机</li>
<li><code>shutdown -h 23:15</code> 指定时间关机</li>
<li><code>halt</code> 立刻关机</li>
<li><code>poweroff</code> 立刻关机</li>
<li><code>shutdown -r now</code> 立刻重启</li>
<li><code>shutdown -r 10</code> 十分钟后重启</li>
<li><code>reboot</code> 立刻重启</li>
</ul>
<h2 id="目录或文件操作">目录或文件操作</h2>
<h3 id="切换目录">切换目录</h3>
<ul>
<li><code>cd /</code> 切换到根目录</li>
<li><code>cd /etc</code> 切换到根目录下的etc目录</li>
<li><code>cd ..</code> 切换到上级目录</li>
<li><code>cd ~</code> 切换到家目录</li>
<li><code>cd -</code> 切换到上次访问目录</li>
</ul>
<h3 id="查看目录">查看目录</h3>
<ul>
<li><code>pwd</code> 显示当前目录</li>
<li><code>ls</code> 查看当前目录下的所有文件 <strong>-a</strong> 显示隐藏文件 <strong>-l</strong> 显示详细信息 <strong>-d</strong> 仅显示目录</li>
<li><code>ls</code> /usr/local 查看local目录下所有文件</li>
</ul>
<h3 id="查看文件">查看文件</h3>
<ul>
<li><code>cat</code> 从头显示文件</li>
<li><code>nl</code> 显示行号</li>
<li><code>more</code> 分页显示</li>
<li><code>less</code> 分页显示，可以往前翻页</li>
<li><code>tail</code> 只看后面几行</li>
<li><code>tail -f -n 50 xx.log</code> 持续查看后50行内容</li>
</ul>
<h3 id="创建">创建</h3>
<ul>
<li><code>mkdir tmp</code> 在当前目录下创建tmp目录 <strong>-p</strong> 递归创建</li>
<li><code>touch</code> 创建文件</li>
</ul>
<h3 id="删除">删除</h3>
<ul>
<li><code>rmdir</code> 删除空目录</li>
<li><code>rm</code> 删除文件，也可删除目录 <strong>-r</strong> 递归删除 <strong>-f</strong> 强制删除</li>
</ul>
<h3 id="修改">修改</h3>
<ul>
<li><code>mv</code> 移动或重命名</li>
<li><code>cp</code> 复制 <strong>-r</strong> 递归复制</li>
</ul>
<h3 id="搜索">搜索</h3>
<ul>
<li><code>find /etc -name 'a*'</code> 查找etc目录下a开头的文件</li>
<li><code>grep</code> 在文件中查找某个字符串， 经常与管道符一起使用   <code>ps -aux | grep java</code></li>
</ul>
<h2 id="系统">系统</h2>
<ul>
<li><code>uname</code> 显示系统信息</li>
<li><code>ps</code> 显示进程  <code>ps -aux</code></li>
<li><code>kill</code> 杀死进程</li>
<li><code>systemctl enable [service]</code> 开机启动服务</li>
<li><code>systemctl disable [service]</code> 取消开机启动</li>
<li><code>systemctl start [service]</code> 启动服务</li>
<li><code>systemctl stop [service]</code> 停止服务</li>
<li><code>systemctl restart [service]</code> 重启服务</li>
<li><code>systemctl reload [service]</code> 重新加载服务配置文件</li>
<li><code>systemctl status [service]</code> 服务运行状态</li>
</ul>
<h2 id="压缩文件">压缩文件</h2>
<p><strong>.tar</strong> 是打包文件 <strong>.tar.gz</strong>是打包并压缩文件</p>
<ul>
<li><code>tar -zcvf test.tar.gz test</code> 将test文件打包并压缩 <strong>-c</strong> 打包 <strong>-z</strong>压缩或解压 <strong>-v</strong> 显示过程 <strong>-f</strong> 指定文件</li>
<li><code>tar -zxvf test.tar.gz -C /tmp</code>  解压文件到tmp目录 <strong>-x</strong> 拆包</li>
</ul></div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2021-11-10</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span><a href="javascript:void(0);" title="分享到 微博" data-sharer="weibo" data-url="http://example.org/%E5%9F%BA%E7%A1%80%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" data-title="Linux基础常用命令"><i class="fab fa-weibo fa-fw"></i></a></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/linux/">Linux</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/yum/" class="prev" rel="prev" title="了解yum"><i class="fas fa-angle-left fa-fw"></i>了解yum</a>
            <a href="/%E7%B3%BB%E7%BB%9F%E7%9B%AE%E5%BD%95/" class="next" rel="next" title="Linux系统目录结构">Linux系统目录结构<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
<div id="comments"></div></article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.89.0">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2021</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">Cuasloi</a></span>&nbsp;|&nbsp;<span class="license"><a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/lib/sharer/sharer.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{},"search":{"highlightTag":"em","lunrIndexURL":"/index.json","lunrLanguageCode":"zh","lunrSegmentitURL":"/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"lunr"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
